//c 
#if 0

//init()
//push()
//pop()
//print() 

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>

#define MAXSIZE 20

typedef struct {
	int front;
	int rear;
	int data[MAXSIZE];
}Queue;

void Init(Queue* q) {
	q->front = q->rear = 0;
}

void push(Queue* q, int value) {
	int rearplus = (q->rear + 1) % MAXSIZE;
	assert(rearplus != q->front);

	q->data[q->rear] = value;
	q->rear = rearplus;
}

int pop(Queue* q) {
	assert(q->front != q->rear);

	int t = q->data[q->front];
	q->front = (q->front + 1) % MAXSIZE;
	return t;
}

int top(Queue* q) {
	assert(q->front != q->rear);

	int t = q->data[q->front];
	return t;
}

void print(Queue* q) {
	if (q->front == q->rear) {
		printf("The Queue is Empty!\n");
		return;
	}

	int curr = q->front;
	char* seperator = "";
	printf("The Queue from front to rear : ");
	while (curr != q->rear) {
		printf("%s%d", seperator, q->data[curr]);
		curr = (curr + 1) % MAXSIZE;
		seperator = "->";
	}
	printf("\n");
}

int main() {
	Queue p;
	Init(&p);
	print(&p);

	for (int i = 0; i < 3; ++i) {
		push(&p, i);
	}
	print(&p);

	int t = pop(&p);
	printf("poped is : %d\n", t);
	print(&p);

	t = pop(&p);
	printf("poped is : %d\n", t);
	print(&p);

	t = pop(&p);
	printf("poped is : %d\n", t);
	print(&p);

	system("pause");
}

#endif